// GraphicsDevice.cs
//

using System;
using System.Collections.Generic;
using System.Html;
using System.Html.Media.Graphics;

namespace Moonbeam.Core
{
    public class GraphicsDevice
    {
        CanvasElement canvas;
        CanvasContext2D context;

        public GraphicsDevice(string _canvasName)
        {
            canvas = (CanvasElement)Document.GetElementById(_canvasName);

            context = (CanvasContext2D)canvas.GetContext(Rendering.Render2D);            
        }

        public void SetViewport(int _height, int _width)
        {
            canvas.Height = _height;
            canvas.Width = _width;

            Clear();
        }

        public CanvasContext2D GetDrawingSurface()
        {            
            return context;
        }

        public CanvasElement GetRenderingWindow()
        {
            return canvas;
        }

        public void Clear()
        {
            context.FillStyle = Colour.Cornflowerblue;
            context.FillRect(0, 0, canvas.Width, canvas.Height);
        }
    }
}
